package com.xoa.service.party;

import com.xoa.dao.department.DepartmentMapper;
import com.xoa.dao.party.*;
import com.xoa.model.department.Department;
import com.xoa.model.party.GridEveromentUser;
import com.xoa.model.party.GridEveromentcheck;
import com.xoa.model.party.GridHoliday;
import com.xoa.model.party.OrgGoviment;
import com.xoa.util.DateFormat;
import com.xoa.util.ToJson;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * Created by gsb on 2018/1/12.
 */
@Service
public class GridEveromentcheckService {

    @Resource
    private GridEveromentcheckMapper gridEveromentcheckMapper;

    @Resource
    private GridHolidayMapper gridHolidayMapper;

    @Resource
    private GridEveromentUserMapper gridEveromentUserMapper;

    @Resource
    private GridEveromentUserService gridEveromentUserService;

    @Resource
    private GridEveromentcheckService gridEveromentcheckService;
    @Resource
    private ThirdPartyService thirdPartyService;

    @Resource
    private DepartmentMapper departmentMapper;
    @Resource
    private OrgGovimentMapper orgGovimentMapper;
    @Resource
    private GridEventMapper gridEventMapper;
    /**
     *
     * 创建作者:   季佳伟
     * 创建日期:   2018-1-12 下午15:26:51
     * 类介绍  : 社区   签到情况
     *   key=0  为周末   key=1 为工作日
     *   isPage
     * 构造参数:
     *
     */
    public ToJson<GridEveromentcheck> select(String time, String key, Integer page, Integer pageSize,
                                             boolean useFlag){
        ToJson<GridEveromentcheck> json = new ToJson<>();
        try {
            String isPage = "1";
            List<Department> departmentList = departmentMapper.getChDept(27);
            GridEveromentcheck gridEveromentcheck = null;
            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
            Date date=sdf.parse(time);
            if(time.equals(DateFormat.getCurrentTime2())){
                List<GridEveromentcheck> gridEveromentcheckList = new ArrayList<>();
                  if (departmentList!=null && departmentList.size()>0){
                        for (Department department:departmentList){
                            gridEveromentcheck = new GridEveromentcheck();
                            gridEveromentcheck.setGridId(department.getDeptId().toString());
                            gridEveromentcheck.setGridName(department.getDeptName());

                            gridEveromentcheck.setDate(date);
                            ToJson<GridEveromentUser> gridEveromentUserToJson = gridEveromentUserService.selectCheck(time, key,
                                    department.getDeptId(), page, pageSize, useFlag,isPage);
                            List<GridEveromentUser> gridEveromentUserList = gridEveromentUserToJson.getObj();
                            int count = 0;
                            int score = 0;
                            //查询前端传入时间是否在节假日范围内
                            Map<String, Object> map1 = new HashMap<String, Object>();
                            map1.put("newTime",time);
                            List<GridHoliday> gridHolidayList =gridHolidayMapper.selectHoliday(map1);
                            int userNum = gridEveromentUserMapper.selectCount(department.getDeptId());
                            gridEveromentcheck.setGridNum(userNum+"");
                            if(gridEveromentUserList!=null && gridEveromentUserList.size()>0){
                                for (GridEveromentUser gridEveromentUser:gridEveromentUserList){
                                    if ("1".equals(gridEveromentUser.getM1())){
                                        count=count+1;
                                    }
                                }
                            }
                            if (gridHolidayList!=null && gridHolidayList.size()>0){
                                gridEveromentcheck.setAttendScore("0");
                            }else {
//                                score = count - userNum;
                                score = count;
                                gridEveromentcheck.setAttendScore(score+"");
                            }
                            gridEveromentcheck.setAttendNum(count+"");
                            gridEveromentcheck.setAttendScore(score+"");
                            gridEveromentcheckList.add(gridEveromentcheck);
                           /* Map<String, Object> map = new HashMap<String, Object>();
                            map.put("gridId",department.getDeptId());
                            map.put("newdate",date);
                            List<GridEveromentcheck> gridEveromentcheckList = gridEveromentcheckMapper.selectEveromentCheck(map);
                            if (gridEveromentcheckList!=null &&gridEveromentcheckList.size()>0){
                                gridEveromentcheck.setEid(gridEveromentcheckList.get(0).getEid());
                                gridEveromentcheckMapper.updateByPrimaryKeySelective(gridEveromentcheck);
                            }else {
                                gridEveromentcheckMapper.insertSelective(gridEveromentcheck);
                            }*/
                        }
                  }
                    json.setObj(gridEveromentcheckList);
                    json.setFlag(0);
                    json.setMsg("ok");
            }else {
                Map<String, Object> map2 = new HashMap<String, Object>();
                map2.put("newdate",date);
                List<GridEveromentcheck> gridEveromentcheck1 = gridEveromentcheckMapper.selectEveromentCheck(map2);
                json.setObj(gridEveromentcheck1);
                json.setTotleNum(gridEveromentcheckMapper.selectEveromentCount(map2));
                json.setFlag(0);
                json.setMsg("ok");
            }
        }catch (Exception e){
            e.printStackTrace();
            json.setFlag(1);
            json.setMsg(e.getMessage());
        }
        return json;
    }

    /**
     * 定时添加当天社区巡检记录
     * @return
     */
    public ToJson<GridEveromentcheck> getCheckCountInsert() {
        ToJson<GridEveromentcheck> json = new ToJson<>();
        try {
            int a =0 ;
//            int b = 0;
            int sum = 0;
            float c = 0 ;
            Date d1 = new Date();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//获取当天日期
            String time = sdf.format(d1);
            /*SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String time = "2018-01-25";*/
            Date date=sdf.parse(time);
            Map<String, Object> map5 = new HashMap<String, Object>();
            map5.put("newdate",time);
            List<GridEveromentcheck> gridEveromentcheckList5 = gridEveromentcheckMapper.selectEveromentCheck(map5);//查询当天环保考核社区表的记录
            if (gridEveromentcheckList5 != null && gridEveromentcheckList5.size()>0){//如果不等于空并且大于0 则返回不添加
                json.setFlag(1);
                return json;
            }
            //查询社区列表
            List<Department> list = departmentMapper.getChDept(27);//查询居委化下所有的社区
            OrgGoviment orgGoviment=new OrgGoviment();
            if(list!=null){
                for(Department department:list){
                    //获取网格员数
                    int b = 0;
                    a=orgGovimentMapper.orgGovimentUserCount(department.getDeptId());//查询该部门下有多少人
                    //查询对应社区下人员名称
                    List<OrgGoviment> list1 =orgGovimentMapper.orgGovimentUser(department.getDeptId());
                    for (OrgGoviment orgGoviment1:list1){
                        //获取巡查统计数
                        HashMap<String, Object> map = new HashMap<String, Object>();
                        map.put("deptId",department.getDeptId());
                        map.put("userId",orgGoviment1.getUserId());
                        map.put("checkTime",time);
                        int coun =orgGovimentMapper.getCheckCount(map);
                        //获取巡检记录总数
                        b += Integer.valueOf(coun);
                    }
                    //巡检记录平均数(巡检记录数/网格员数，保留2位小数)
                    if (a!=0){
                        c = (float)b/a;
                    }
                    DecimalFormat df = new DecimalFormat("######0.00");
                    df.format(c);
                    //获取分数（巡检记录平均数-1）*10，保留整数，可以有负值。）
                    //float f=1.1f;//定义一个浮点变量a
                    sum = (int)((c -1 ) * 10);
                    GridEveromentcheck gridEveromentcheck =new GridEveromentcheck();
                    gridEveromentcheck.setGridNum(String.valueOf(a));
                    gridEveromentcheck.setGridId(String.valueOf(department.getDeptId()));
                    gridEveromentcheck.setGridName(department.getDeptName());
                    gridEveromentcheck.setDate(date);
                    gridEveromentcheck.setCheckRecordNum(String.valueOf(b));
                    gridEveromentcheck.setCheckRecordAverage(String.valueOf(df.format(c)));
                    gridEveromentcheck.setCheckScore(String.valueOf(b));

                    Map<String, Object> map = new HashMap<String, Object>();
                    map.put("gridId",department.getDeptId());
                    map.put("newdate",time);
                    List<GridEveromentcheck> gridEveromentcheckList = gridEveromentcheckMapper.selectEveromentCheck(map);
                    if (gridEveromentcheckList!=null &&gridEveromentcheckList.size()>0){
                        gridEveromentcheck.setEid(gridEveromentcheckList.get(0).getEid());
                        gridEveromentcheckMapper.updateByPrimaryKeySelective(gridEveromentcheck);
                        for(GridEveromentcheck gridEveromentcheck1:gridEveromentcheckList){
                            if(!gridEveromentcheck1.getEid().equals(gridEveromentcheckList.get(0).getEid())){
                                gridEveromentcheckMapper.deleteByPrimaryKey(gridEveromentcheck1.getEid());
                            }
                        }

                    }else {
                        gridEveromentcheckMapper.insertSelective(gridEveromentcheck);
                    }
                }
                json.setFlag(0);
                json.setMsg("ok");
            }

        }catch (Exception e){
            e.printStackTrace();
            json.setFlag(1);
            json.setMsg(e.getMessage());
        }
        return json;
    }
    public ToJson<GridEveromentcheck> getCheckCountInsert1(String DateTime) {
        ToJson<GridEveromentcheck> json = new ToJson<>();
        try {
            int a =0 ;
//            int b = 0;
            int sum = 0;
            float c = 0 ;
           // Date d1 = new Date();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
           // String time = sdf.format(d1);
            /*SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String time = "2018-01-25";*/
            Date date=sdf.parse(DateTime);
            //查询社区列表
            List<Department> list = departmentMapper.getChDept(27);
            OrgGoviment orgGoviment=new OrgGoviment();
            if(list!=null){
                for(Department department:list){
                    //获取网格员数
                    int b = 0;
                    a=orgGovimentMapper.orgGovimentUserCount(department.getDeptId());
                    //查询对应社区下人员名称
                    List<OrgGoviment> list1 =orgGovimentMapper.orgGovimentUser(department.getDeptId());
                    for (OrgGoviment orgGoviment1:list1){
                        //获取巡查统计数
                        HashMap<String, Object> map = new HashMap<String, Object>();
                        map.put("deptId",department.getDeptId());
                        map.put("userId",orgGoviment1.getUserId());
                        map.put("checkTime",DateTime);
                        int coun =orgGovimentMapper.getCheckCount(map);
                        //获取巡检记录总数
                        b += Integer.valueOf(coun);
                    }
                    //巡检记录平均数(巡检记录数/网格员数，保留2位小数)
                    c = (float)b/a;
                    DecimalFormat df = new DecimalFormat("######0.00");
                    df.format(c);
                    //获取分数（巡检记录平均数-1）*10，保留整数，可以有负值。）
                    //float f=1.1f;//定义一个浮点变量a
                    sum = (int)((c -1 ) * 10);
                    GridEveromentcheck gridEveromentcheck =new GridEveromentcheck();
                    gridEveromentcheck.setGridNum(String.valueOf(a));
                    gridEveromentcheck.setGridId(String.valueOf(department.getDeptId()));
                    gridEveromentcheck.setGridName(department.getDeptName());
                    gridEveromentcheck.setDate(date);
                    gridEveromentcheck.setCheckRecordNum(String.valueOf(b));
                    gridEveromentcheck.setCheckRecordAverage(String.valueOf(df.format(c)));
                    gridEveromentcheck.setCheckScore(String.valueOf(sum));

                    Map<String, Object> map = new HashMap<String, Object>();
                    map.put("gridId",department.getDeptId());
                    map.put("newdate",DateTime);
                    List<GridEveromentcheck> gridEveromentcheckList = gridEveromentcheckMapper.selectEveromentCheck(map);
                    if (gridEveromentcheckList!=null &&gridEveromentcheckList.size()>0){
                        gridEveromentcheck.setEid(gridEveromentcheckList.get(0).getEid());
                        gridEveromentcheckMapper.updateByPrimaryKeySelective(gridEveromentcheck);
                        for(GridEveromentcheck gridEveromentcheck1:gridEveromentcheckList){
                            if(!gridEveromentcheck1.getEid().equals(gridEveromentcheckList.get(0).getEid())){
                                gridEveromentcheckMapper.deleteByPrimaryKey(gridEveromentcheck1.getEid());
                            }
                        }
                    }else {
                        gridEveromentcheckMapper.insertSelective(gridEveromentcheck);
                    }
                }
                json.setFlag(0);
                json.setMsg("ok");
            }

        }catch (Exception e){
            e.printStackTrace();
            json.setFlag(1);
            json.setMsg(e.getMessage());
        }
        return json;
    }




    public ToJson<GridEveromentcheck> getCheckCount(HttpServletRequest request, GridEveromentcheck gridEveromentcheck, String time) {
        ToJson<GridEveromentcheck> json = new ToJson<>();
        try {
            int a =0 ;
//            int b = 0;
            int sum = 0;
            double c = 0 ;
            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
            Date date=sdf.parse(time);
            //如果是查询当天数据，只进行查询
            if(time.equals(DateFormat.getCurrentTime2())){
                List<GridEveromentcheck> gridEveromentcheckList = new ArrayList<>();
                //查询社区列表
                List<Department> list = departmentMapper.getChDept(27);
                OrgGoviment orgGoviment=new OrgGoviment();
                if(list!=null){
                    for(Department department:list){
                        //获取网格员数
                        int b = 0;
                        a=orgGovimentMapper.orgGovimentUserCount(department.getDeptId());
                        //查询对应社区下人员名称
                        List<OrgGoviment> list1 =orgGovimentMapper.orgGovimentUser(department.getDeptId());
                        for (OrgGoviment orgGoviment1:list1){
                            //获取巡查统计数
                            HashMap<String, Object> map = new HashMap<String, Object>();
                            map.put("deptId",department.getDeptId());
                            map.put("userId",orgGoviment1.getUserId());
                            map.put("checkTime",time);
                            int coun =orgGovimentMapper.getCheckCount(map);
                            //获取巡检记录总数
                            b += Integer.valueOf(coun);
                        }
                        //巡检记录平均数(巡检记录数/网格员数，保留2位小数)
                        if(a!=0){
                            c = b/a;
                        }
                        DecimalFormat df = new DecimalFormat("######0.00");
                        df.format(c);
                        //获取分数（巡检记录平均数-1）*10，保留整数，可以有负值。）
                        float f=1.1f;//定义一个浮点变量a
                        sum = ((int)c -1 ) * 10;
                        GridEveromentcheck gridEveromentcheck1 =new GridEveromentcheck();
                        gridEveromentcheck1.setGridNum(String.valueOf(a));
                        gridEveromentcheck1.setGridId(String.valueOf(department.getDeptId()));
                        gridEveromentcheck1.setGridName(department.getDeptName());
                        gridEveromentcheck1.setDate(date);
                        gridEveromentcheck1.setCheckRecordNum(String.valueOf(b));
                        gridEveromentcheck1.setCheckRecordAverage(String.valueOf(df.format(c)));
                        gridEveromentcheck1.setCheckScore(String.valueOf(b));
                       gridEveromentcheckList.add(gridEveromentcheck1);

                    }
                   /* Map<String, Object> map = new HashMap<String, Object>();
                    map.put("gridId",department.getDeptId());
                    map.put("newdate",date);
                    List<GridEveromentcheck> gridEveromentcheckList = gridEveromentcheckMapper.selectEveromentCheck(map);
                    if (gridEveromentcheckList!=null &&gridEveromentcheckList.size()>0){
                        gridEveromentcheck.setEid(gridEveromentcheckList.get(0).getEid());
                        gridEveromentcheckMapper.updateByPrimaryKeySelective(gridEveromentcheck);
                    }else {
                        gridEveromentcheckMapper.insertSelective(gridEveromentcheck);
                    }*/
                }
                json.setObj(gridEveromentcheckList);
                json.setFlag(0);
                json.setMsg("ok");
            }else {
                Map<String, Object> map1 = new HashMap<String, Object>();
                map1.put("newdate",date);
                List<GridEveromentcheck> gridEveromentcheck1 = gridEveromentcheckMapper.selectEveromentCheck(map1);
                json.setObj(gridEveromentcheck1);
                json.setTotleNum(gridEveromentcheckMapper.selectEveromentCount(map1));
                json.setFlag(0);
                json.setMsg("ok");
            }

        }catch (Exception e){
            e.printStackTrace();
            json.setFlag(1);
            json.setMsg(e.getMessage());
        }
        return json;
    }

    public ToJson<GridEveromentcheck> getEventCount(HttpServletRequest request, GridEveromentcheck gridEveromentcheck, String time) {
        ToJson<GridEveromentcheck> json = new ToJson<>();
        try {
            int a =0 ;
            int sum = 0;
            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
            Date date=sdf.parse(time);
            if(time.equals(DateFormat.getCurrentTime2())){
                List<GridEveromentcheck> gridEveromentcheckList = new ArrayList<>();
                  //查询社区列表
                List<Department> list = departmentMapper.getChDept(27);
                if(list!=null){
                    for(Department department:list){
                        //获取上报网格数
                        HashMap<String, Object> map = new HashMap<String, Object>();
                        map.put("deptId",department.getDeptId());
                        map.put("eventTime",time);
                        a=gridEventMapper.getEventCountByUserId(map);
                        //获取分数（上报网格数）*(2)）
                        sum = a * 2;
                        GridEveromentcheck gridEveromentcheck1 = new GridEveromentcheck();
                        gridEveromentcheck1.setGridNum(String.valueOf(a));
                        gridEveromentcheck1.setGridId(String.valueOf(department.getDeptId()));
                        gridEveromentcheck1.setGridName(department.getDeptName());
                        gridEveromentcheck1.setDate(date);
                        gridEveromentcheck1.setReportNum(String.valueOf(a));
                        gridEveromentcheck1.setRepoetScore(String.valueOf(sum));
                        gridEveromentcheckList.add(gridEveromentcheck1);

                       /* Map<String, Object> map = new HashMap<String, Object>();
                        map.put("gridId",department.getDeptId());
                        map.put("newdate",date);
                        List<GridEveromentcheck> gridEveromentcheckList = gridEveromentcheckMapper.selectEveromentCheck(map);
                        if (gridEveromentcheckList!=null &&gridEveromentcheckList.size()>0){
                            gridEveromentcheck.setEid(gridEveromentcheckList.get(0).getEid());
                            gridEveromentcheckMapper.updateByPrimaryKeySelective(gridEveromentcheck);
                        }else {
                            gridEveromentcheckMapper.insertSelective(gridEveromentcheck);
                        }*/
                    }
                }
                json.setObj(gridEveromentcheckList);
                json.setFlag(0);
                json.setMsg("ok");

            }else {

                Map<String, Object> map1 = new HashMap<String, Object>();
                map1.put("newdate",date);
                List<GridEveromentcheck> gridEveromentcheck1 = gridEveromentcheckMapper.selectEveromentCheck(map1);
                json.setObj(gridEveromentcheck1);
                json.setTotleNum(gridEveromentcheckMapper.selectEveromentCount(map1));
                json.setFlag(0);
                json.setMsg("ok");
            }

        }catch (Exception e){
            e.printStackTrace();
            json.setFlag(1);
            json.setMsg(e.getMessage());
        }
        return json;

    }

    /**
     * 定时添加每天上报网格数
     * @return
     */
    public ToJson<GridEveromentcheck> getEventCountInsert() {
        ToJson<GridEveromentcheck> json = new ToJson<>();
        try {
            int a =0 ;
            int sum = 0;
            Date d1 = new Date();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String time = sdf.format(d1);
            /*SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String time = "2018-01-25";*/
            Date date=sdf.parse(time);
            //查询社区列表
            List<Department> list = departmentMapper.getChDept(27);
            if(list!=null){
                for(Department department:list){
                    //获取上报网格数
                    HashMap<String, Object> map1 = new HashMap<String, Object>();
                    map1.put("deptId",department.getDeptId());
                    map1.put("eventTime",time);
                    a=gridEventMapper.getEventCountByUserId(map1);
                    //获取分数（上报网格数）*(2)）
                    sum = a * 2;
                    GridEveromentcheck gridEveromentcheck=new GridEveromentcheck();
                    gridEveromentcheck.setGridNum(String.valueOf(a));
                    gridEveromentcheck.setGridId(String.valueOf(department.getDeptId()));
                    gridEveromentcheck.setGridName(department.getDeptName());
                    gridEveromentcheck.setDate(date);
                    gridEveromentcheck.setReportNum(String.valueOf(a));
                    gridEveromentcheck.setRepoetScore(String.valueOf(sum));

                    Map<String, Object> map = new HashMap<String, Object>();
                    map.put("gridId",department.getDeptId());
                    map.put("newdate",time);
                    List<GridEveromentcheck> gridEveromentcheckList = gridEveromentcheckMapper.selectEveromentCheck(map);
                    if (gridEveromentcheckList!=null &&gridEveromentcheckList.size()>0){
                        gridEveromentcheck.setEid(gridEveromentcheckList.get(0).getEid());
                        gridEveromentcheckMapper.updateByPrimaryKeySelective(gridEveromentcheck);
                    }
//                    else {
//                        gridEveromentcheckMapper.insertSelective(gridEveromentcheck);
//                    }
                }
                json.setFlag(0);
                json.setMsg("ok");
            }

        }catch (Exception e){
            e.printStackTrace();
            json.setFlag(1);
            json.setMsg(e.getMessage());
        }
        return json;

    }
    public ToJson<GridEveromentcheck> getEventCountInsert1(String DateTime) {
        ToJson<GridEveromentcheck> json = new ToJson<>();
        try {
            int a =0 ;
            int sum = 0;
//            Date d1 = new Date();
              SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//            String time = sdf.format(d1);
            /*SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String time = "2018-01-25";*/
            Date date=sdf.parse(DateTime);
            //查询社区列表
            List<Department> list = departmentMapper.getChDept(27);
            if(list!=null){
                for(Department department:list){
                    //获取上报网格数
                    HashMap<String, Object> map1 = new HashMap<String, Object>();
                    map1.put("deptId",department.getDeptId());
                    map1.put("eventTime",DateTime);
                    a=gridEventMapper.getEventCountByUserId(map1);
                    //获取分数（上报网格数）*(2)）
                    sum = a * 2;
                    GridEveromentcheck gridEveromentcheck=new GridEveromentcheck();
                    gridEveromentcheck.setGridNum(String.valueOf(a));
                    gridEveromentcheck.setGridId(String.valueOf(department.getDeptId()));
                    gridEveromentcheck.setGridName(department.getDeptName());
                    gridEveromentcheck.setDate(date);
                    gridEveromentcheck.setReportNum(String.valueOf(a));
                    gridEveromentcheck.setRepoetScore(String.valueOf(sum));

                    Map<String, Object> map = new HashMap<String, Object>();
                    map.put("gridId",department.getDeptId());
                    map.put("newdate",DateTime);
                    List<GridEveromentcheck> gridEveromentcheckList = gridEveromentcheckMapper.selectEveromentCheck(map);
                    if (gridEveromentcheckList!=null &&gridEveromentcheckList.size()>0){
                        gridEveromentcheck.setEid(gridEveromentcheckList.get(0).getEid());
                        gridEveromentcheckMapper.updateByPrimaryKeySelective(gridEveromentcheck);
                        for(GridEveromentcheck gridEveromentcheck1:gridEveromentcheckList){
                            if(!gridEveromentcheck1.getEid().equals(gridEveromentcheckList.get(0).getEid())){
                                gridEveromentcheckMapper.deleteByPrimaryKey(gridEveromentcheck1.getEid());
                            }
                        }
                    }else {
                        gridEveromentcheckMapper.insertSelective(gridEveromentcheck);
                    }
                }
                json.setFlag(0);
                json.setMsg("ok");
            }

        }catch (Exception e){
            e.printStackTrace();
            json.setFlag(1);
            json.setMsg(e.getMessage());
        }
        return json;

    }

    public ToJson<GridEveromentcheck> handOpration(String dateTime) {
        //环保考核查询记录并保存
        gridEveromentcheckService.getCheckCountInsert1(dateTime);
        gridEveromentcheckService.getEventCountInsert1(dateTime);
        gridEveromentUserService.getCheckCountNumInsert1(dateTime);
        gridEveromentUserService.getEventCountNumInsert1(dateTime);
        thirdPartyService.insertGridAttend1(dateTime);
        thirdPartyService.insertThird1(dateTime);
        thirdPartyService.insertDayUserScore1(dateTime);
        thirdPartyService.insertDayGridScore1(dateTime);
        return new ToJson<>();
    }
}
